package it.polito.let.filesystem;


public class FileConstants {
	public static final String JHPSRC = "jhp";
	public static final String JAVASRC = "java";
	public static final String JAVABIN = "class";
	public static final String pkgRegexp = "(([a-zA-Z0-9_]+)\\s*\\.\\s*)+[a-zA-Z0-9_]+\\s*";

	public enum FileType {

		JAVA("java"),
		JAVABIN("class"),
		JHP("jhp"),
		NOEXT(""),
		OTHER("");

		private String ext;

		FileType(String ext) {
			this.ext = ext;
		}

		public String extension() {
			return ext;
		}

		public String value() {
			return name();
		}

		public static FileType fromValue(String v) {
			return valueOf(v);
		}

		public static FileType fromExtension(String ext) {
			if (ext==null || ext.trim().length()==0)
				return NOEXT;
			for (FileType t:FileType.values()) {
				if (t.extension().equalsIgnoreCase(ext))
					return t;
			}
			return OTHER;
		}
	}
}
